import { EntitySchema } from '@mikro-orm/core';

export class TypechoApiconfig {
  id!: number;
  webinfoTitle!: string;
  webinfoUrl!: string;
  webinfoUploadUrl!: string;
  webinfoAvatar!: string;
  pexelsKey!: string;
  scale: number = 100;
  clock: number = 5;
  vipPrice: number = 200;
  vipDay: number = 300;
  vipDiscount!: string;
  isEmail: number = 1;
  isInvite: number = 0;
  cosAccessKey!: string;
  cosSecretKey!: string;
  cosBucket!: string;
  cosBucketName!: string;
  cosPath?: string;
  cosPrefix!: string;
  aliyunEndpoint!: string;
  aliyunAccessKeyId!: string;
  aliyunAccessKeySecret!: string;
  aliyunAucketName!: string;
  aliyunUrlPrefix!: string;
  aliyunFilePrefix!: string;
  ftpHost!: string;
  ftpPort: number = 21;
  ftpUsername!: string;
  ftpPassword!: string;
  ftpBasePath!: string;
  alipayAppId!: string;
  alipayPrivateKey?: string;
  alipayPublicKey?: string;
  alipayNotifyUrl!: string;
  appletsAppid!: string;
  appletsSecret?: string;
  wxpayAppId!: string;
  wxpayMchId!: string;
  wxpayKey?: string;
  wxpayNotifyUrl?: string;
  auditlevel?: number = 1;
  forbidden?: string;
  qqAppletsAppid?: string;
  qqAppletsSecret?: string;
  wxAppId?: string;
  wxAppSecret?: string;
  fields?: string;
  pushAdsPrice: number = 100;
  pushAdsNum: number = 10;
  bannerAdsPrice: number = 100;
  bannerAdsNum: number = 5;
  startAdsPrice: number = 100;
  startAdsNum: number = 1;
  epayUrl?: string;
  epayPid?: number;
  epayKey?: string;
  epayNotifyUrl?: string;
  mchSerialNo?: string;
  mchApiV3Key?: string;
  cloudUid?: string;
  cloudUrl?: string;
  pushAppId?: string;
  pushAppKey?: string;
  pushMasterSecret?: string;
  isPush?: number = 0;
  disableCode?: number = 0;
  allowDelete?: number = 0;
  contentAuditlevel?: number = 2;
  uploadLevel?: number = 0;
  clockExp?: number = 5;
  reviewExp?: number = 1;
  postExp?: number = 10;
  violationExp?: number = 50;
  deleteExp?: number = 20;
  spaceMinExp?: number = 20;
  chatMinExp?: number = 20;
  qiniuDomain?: string;
  qiniuAccessKey?: string;
  qiniuSecretKey?: string;
  qiniuBucketName?: string;
  silenceTime?: number = 600;
  interceptTime?: number = 3600;
  isLogin?: number = 0;
  postMax?: number = 5;
  forumAudit?: number = 1;
  spaceAudit?: number = 0;
  uploadType?: string;
  banRobots?: number = 0;
  adsGiftNum?: number = 10;
  adsGiftAward?: number = 5;
}

export const TypechoApiconfigSchema = new EntitySchema({
  class: TypechoApiconfig,
  properties: {
    id: { primary: true, type: 'number' },
    webinfoTitle: { type: 'string', fieldName: 'webinfoTitle', length: 500 },
    webinfoUrl: { type: 'string', fieldName: 'webinfoUrl', length: 500 },
    webinfoUploadUrl: {
      type: 'string',
      fieldName: 'webinfoUploadUrl',
      length: 255,
      default: 'http://127.0.0.1:8081/',
    },
    webinfoAvatar: {
      type: 'string',
      fieldName: 'webinfoAvatar',
      length: 500,
      default: 'https://cdn.helingqi.com/wavatar/',
    },
    pexelsKey: { type: 'string', fieldName: 'pexelsKey', length: 255 },
    scale: { type: 'number', default: 100 },
    clock: { type: 'number', default: 5 },
    vipPrice: { type: 'number', fieldName: 'vipPrice', default: 200 },
    vipDay: { type: 'number', fieldName: 'vipDay', default: 300 },
    vipDiscount: { type: 'string', fieldName: 'vipDiscount', length: 11, default: '0.1' },
    isEmail: { type: 'number', fieldName: 'isEmail', default: 1 },
    isInvite: { type: 'number', fieldName: 'isInvite', default: 0 },
    cosAccessKey: { type: 'string', fieldName: 'cosAccessKey', length: 300 },
    cosSecretKey: { type: 'string', fieldName: 'cosSecretKey', length: 300 },
    cosBucket: { type: 'string', fieldName: 'cosBucket', length: 255 },
    cosBucketName: { type: 'string', fieldName: 'cosBucketName', length: 255 },
    cosPath: { type: 'string', fieldName: 'cosPath', length: 255, nullable: true },
    cosPrefix: { type: 'string', fieldName: 'cosPrefix', length: 255 },
    aliyunEndpoint: { type: 'string', fieldName: 'aliyunEndpoint', length: 500 },
    aliyunAccessKeyId: { type: 'string', fieldName: 'aliyunAccessKeyId', length: 255 },
    aliyunAccessKeySecret: { type: 'string', fieldName: 'aliyunAccessKeySecret', length: 255 },
    aliyunAucketName: { type: 'string', fieldName: 'aliyunAucketName', length: 255 },
    aliyunUrlPrefix: { type: 'string', fieldName: 'aliyunUrlPrefix', length: 255 },
    aliyunFilePrefix: { type: 'string', fieldName: 'aliyunFilePrefix', length: 255 },
    ftpHost: { type: 'string', fieldName: 'ftpHost', length: 255 },
    ftpPort: { type: 'number', fieldName: 'ftpPort', default: 21 },
    ftpUsername: { type: 'string', fieldName: 'ftpUsername', length: 255 },
    ftpPassword: { type: 'string', fieldName: 'ftpPassword', length: 255 },
    ftpBasePath: { type: 'string', fieldName: 'ftpBasePath', length: 255 },
    alipayAppId: { type: 'string', fieldName: 'alipayAppId', length: 255 },
    alipayPrivateKey: {
      type: 'string',
      fieldName: 'alipayPrivateKey',
      columnType: 'text',
      nullable: true,
    },
    alipayPublicKey: {
      type: 'string',
      fieldName: 'alipayPublicKey',
      columnType: 'text',
      nullable: true,
    },
    alipayNotifyUrl: { type: 'string', fieldName: 'alipayNotifyUrl', length: 500 },
    appletsAppid: { type: 'string', fieldName: 'appletsAppid', length: 255 },
    appletsSecret: {
      type: 'string',
      fieldName: 'appletsSecret',
      columnType: 'text',
      nullable: true,
    },
    wxpayAppId: { type: 'string', fieldName: 'wxpayAppId', length: 255 },
    wxpayMchId: { type: 'string', fieldName: 'wxpayMchId', length: 255 },
    wxpayKey: { type: 'string', fieldName: 'wxpayKey', columnType: 'text', nullable: true },
    wxpayNotifyUrl: { type: 'string', fieldName: 'wxpayNotifyUrl', length: 500, nullable: true },
    auditlevel: { type: 'number', nullable: true, default: 1 },
    forbidden: { type: 'string', columnType: 'text', nullable: true },
    qqAppletsAppid: { type: 'string', fieldName: 'qqAppletsAppid', length: 500, nullable: true },
    qqAppletsSecret: { type: 'string', fieldName: 'qqAppletsSecret', length: 500, nullable: true },
    wxAppId: { type: 'string', fieldName: 'wxAppId', length: 500, nullable: true },
    wxAppSecret: { type: 'string', fieldName: 'wxAppSecret', length: 500, nullable: true },
    fields: { type: 'string', length: 500, nullable: true, default: 'able' },
    pushAdsPrice: { type: 'number', fieldName: 'pushAdsPrice', default: 100 },
    pushAdsNum: { type: 'number', fieldName: 'pushAdsNum', default: 10 },
    bannerAdsPrice: { type: 'number', fieldName: 'bannerAdsPrice', default: 100 },
    bannerAdsNum: { type: 'number', fieldName: 'bannerAdsNum', default: 5 },
    startAdsPrice: { type: 'number', fieldName: 'startAdsPrice', default: 100 },
    startAdsNum: { type: 'number', fieldName: 'startAdsNum', default: 1 },
    epayUrl: { type: 'string', fieldName: 'epayUrl', length: 500, nullable: true },
    epayPid: { type: 'number', fieldName: 'epayPid', nullable: true },
    epayKey: { type: 'string', fieldName: 'epayKey', length: 300, nullable: true },
    epayNotifyUrl: { type: 'string', fieldName: 'epayNotifyUrl', length: 500, nullable: true },
    mchSerialNo: { type: 'string', fieldName: 'mchSerialNo', columnType: 'text', nullable: true },
    mchApiV3Key: { type: 'string', fieldName: 'mchApiV3Key', columnType: 'text', nullable: true },
    cloudUid: { type: 'string', fieldName: 'cloudUid', length: 255, nullable: true },
    cloudUrl: { type: 'string', fieldName: 'cloudUrl', length: 255, nullable: true },
    pushAppId: { type: 'string', fieldName: 'pushAppId', length: 255, nullable: true },
    pushAppKey: { type: 'string', fieldName: 'pushAppKey', length: 255, nullable: true },
    pushMasterSecret: { type: 'string', fieldName: 'pushMasterSecret', length: 255, nullable: true },
    isPush: { type: 'number', fieldName: 'isPush', nullable: true, default: 0 },
    disableCode: { type: 'number', fieldName: 'disableCode', nullable: true, default: 0 },
    allowDelete: { type: 'number', fieldName: 'allowDelete', nullable: true, default: 0 },
    contentAuditlevel: { type: 'number', fieldName: 'contentAuditlevel', nullable: true, default: 2 },
    uploadLevel: { type: 'number', fieldName: 'uploadLevel', nullable: true, default: 0 },
    clockExp: { type: 'number', fieldName: 'clockExp', nullable: true, default: 5 },
    reviewExp: { type: 'number', fieldName: 'reviewExp', nullable: true, default: 1 },
    postExp: { type: 'number', fieldName: 'postExp', nullable: true, default: 10 },
    violationExp: { type: 'number', fieldName: 'violationExp', nullable: true, default: 50 },
    deleteExp: { type: 'number', fieldName: 'deleteExp', nullable: true, default: 20 },
    spaceMinExp: { type: 'number', fieldName: 'spaceMinExp', nullable: true, default: 20 },
    chatMinExp: { type: 'number', fieldName: 'chatMinExp', nullable: true, default: 20 },
    qiniuDomain: { type: 'string', fieldName: 'qiniuDomain', length: 400, nullable: true },
    qiniuAccessKey: { type: 'string', fieldName: 'qiniuAccessKey', length: 400, nullable: true },
    qiniuSecretKey: { type: 'string', fieldName: 'qiniuSecretKey', length: 400, nullable: true },
    qiniuBucketName: { type: 'string', fieldName: 'qiniuBucketName', length: 255, nullable: true },
    silenceTime: { type: 'number', fieldName: 'silenceTime', nullable: true, default: 600 },
    interceptTime: { type: 'number', fieldName: 'interceptTime', nullable: true, default: 3600 },
    isLogin: { type: 'number', fieldName: 'isLogin', nullable: true, default: 0 },
    postMax: { type: 'number', fieldName: 'postMax', nullable: true, default: 5 },
    forumAudit: { type: 'number', fieldName: 'forumAudit', nullable: true, default: 1 },
    spaceAudit: { type: 'number', fieldName: 'spaceAudit', nullable: true, default: 0 },
    uploadType: {
      type: 'string',
      fieldName: 'uploadType',
      length: 100,
      nullable: true,
      default: 'local',
    },
    banRobots: { type: 'number', fieldName: 'banRobots', nullable: true, default: 0 },
    adsGiftNum: { type: 'number', fieldName: 'adsGiftNum', nullable: true, default: 10 },
    adsGiftAward: { type: 'number', fieldName: 'adsGiftAward', nullable: true, default: 5 },
  },
});
